<html> 
<head>
   <style>
      .outline{border:solid black 1px;padding: 5px; margin: 5px;font-weight:bold;}
      .hide{display:none;}
      .t1{background-color:ffffff;}
      .t2{background-color:eeeeee;}
      .t3{background-color:dddddd;}
      .t4{background-color:cccccc;}
      .t5{background-color:bbbbbb;}
      .t6{background-color:aaaaaa;}
   </style>
</head>
<body>
<div class='outline t1' id='complete-div'>
   E/M Code Calculator: 
   <br>
   <div class='outline t2'>
      patient: 
      <br>
      <input class='cpt patient' name='patient' type='radio' value='1' checked='checked'>New
      <input class='cpt patient' name='patient' type='radio' value='2'>Established
      <div class='outline t3' id='patient-1'>
         <input class='em-codes' type='radio' id='em-codes_0' name='em-codes' value='99201'>99201
         <input class='em-codes' type='radio' id='em-codes_1' name='em-codes' value='99202'>99202
         <input class='em-codes' type='radio' id='em-codes_2' name='em-codes' value='99203'>99203
         <input class='em-codes' type='radio' id='em-codes_3' name='em-codes' value='99204'>99204
         <input class='em-codes' type='radio' id='em-codes_4' name='em-codes' value='99205'>99205
      </div>      
      <div class='outline t3 hide' id='patient-2'>
         <input class='em-codes' type='radio' id='em-codes_5' name='em-codes' value='99211'>99211
         <input class='em-codes' type='radio' id='em-codes_6' name='em-codes' value='99212'>99212
         <input class='em-codes' type='radio' id='em-codes_7' name='em-codes' value='99213'>99213
         <input class='em-codes' type='radio' id='em-codes_8' name='em-codes' value='99214'>99214
         <input class='em-codes' type='radio' id='em-codes_9' name='em-codes' value='99215'>99215
      </div>
      time:
      <br>
      <input id='overhalf' class='cpt time' type='checkbox' value='1'>Half Time spent on Coordination
      <div class='outline t3' id='time-1'>
         <input class='cpt time duration' type='radio' name='duration' value='0'>N/A
         <input class='cpt time duration' type='radio' name='duration' value='1'>1 - 19
         <input class='cpt time duration' type='radio' name='duration' value='2'>20 - 29
         <input class='cpt time duration' type='radio' name='duration' value='3'>30 - 44
         <input class='cpt time duration' type='radio' name='duration' value='4'>45 - 59
         <input class='cpt time duration' type='radio' name='duration' value='5'>60 and up
      </div>
      <div class='outline t3 hide' id='time-2'>
         <input class='cpt time duration' type='radio' name='duration' value='0'>N/A
         <input class='cpt time duration' type='radio' name='duration' value='1'>1 - 9
         <input class='cpt time duration' type='radio' name='duration' value='2'>10 - 14
         <input class='cpt time duration' type='radio' name='duration' value='3'>15 - 24
         <input class='cpt time duration' type='radio' name='duration' value='4'>25 - 39
         <input class='cpt time duration' type='radio' name='duration' value='5'>40 and up
      </div>
      <!-- div id='uhp'>
         <input uhp='cptinput' idx='2' id='uhp-em' type='text' />
         <input uhp='cptinput' idx='201' id='uhp-hist-cc' type='text' />
         <input uhp='cptinput' idx='2031' id='uhp-hist-pfsh-past' type='text' />
         <input uhp='cptinput' idx='2032' id='uhp-hist-pfsh-fam' type='text' />
         <input uhp='cptinput' idx='2033' id='uhp-hist-pfsh-soc' type='text' />
      </div -->

   </div>
   <div class='outline t2' id='exam'>
      <a href='#' class='hidetoggle'>[ + ]</a>Exam Component Detail: <span id='examcode'></span>
      <input class='cpt exam' name='exam' type='radio' value='0'>N/A 
      <input class='cpt exam' name='exam' type='radio' value='1'>Poblem Focused
      <input class='cpt exam' name='exam' type='radio' value='2'>Extended Problem Focused
      <input class='cpt exam' name='exam' type='radio' value='3'>Detailed 
      <input class='cpt exam' name='exam' type='radio' value='4'>Complete
      <div class='outline t3 hide'>
         Constitutional: <input class='cpt cons' type='checkbox' value='1'>3/7 vitals
                         <input class='cpt cons' type='checkbox' value='1'>General Appearance
      </div>
      <div class='outline t3 hide'>
         Musculoskeletal:<input class='cpt musc' type='checkbox' value='1'>Muscle Strength and tone
                         <input class='cpt musc' type='checkbox' value='1'>Gait and station
      </div>
      <div class='outline t3 hide'>
         Psychiatric:    <input class='cpt psych' type='checkbox' value='1'>Speech
                         <input class='cpt psych' type='checkbox' value='1'>Thought Process
                         <input class='cpt psych' type='checkbox' value='1'>Associations
                         <input class='cpt psych' type='checkbox' value='1'>Abnormal/psychotic thoughts
                         <input class='cpt psych' type='checkbox' value='1'>Judgement and insight
                         <input class='cpt psych' type='checkbox' value='1'>Orientation
                         <br>
                         <input class='cpt psych' type='checkbox' value='1'>Memeory
                         <input class='cpt psych' type='checkbox' value='1'>attention
                         <input class='cpt psych' type='checkbox' value='1'>language
                         <input class='cpt psych' type='checkbox' value='1'>knowledge
                         <input class='cpt psych' type='checkbox' value='1'>mood
      </div>
   </div>
   <div class='outline t2' id='hist'>
      <a href='#' class='hidetoggle'>[ + ]</a>History Detail: <span id='histcode'></span>
      <input class='cpt history' name='history' type='radio' value='0'>N/A 
      <input class='cpt history' name='history' type='radio' value='1'>Poblem Focused          
      <input class='cpt history' name='history' type='radio' value='2'>Extended Problem Focused
      <input class='cpt history' name='history' type='radio' value='3'>Detailed                
      <input class='cpt history' name='history' type='radio' value='4'>Complete                
      <div class='outline t3 hide' id='cc'>
         <a href='#' class='hidetoggle'>[ + ]</a>Chief Complaint: 
         <input class='cpt cc' type='checkbox' value='1'> Documented
         <div class='outline t4 hide' id='cc-details'>
            CC Details:<br>
            Symptom<input id='symp' class='cpt cc' type='text'><br>
            Condition<input id='cond' class='cpt cc' type='text'><br>
            Problem<input id='prob' class='cpt cc' type='text'><br>
            Dx<input id='dx' class='cpt cc' type='text'><br>
            Other Condition<input id='other' class='cpt cc' type='text'><br>
            Recommended Return<input id='recom' class='cpt cc' type='text'><br>
         </div>
      </div>
      <div class='outline t3 hide' id='hpi'>
         <a href='#' class='hidetoggle'>[ + ]</a> HPI: 
         <input class='cpt hpi' type='radio' value='0' name='hpi'>None
         <input class='cpt hpi' type='radio' value='1' name='hpi'>Brief
         <input class='cpt hpi' type='radio' value='2' name='hpi'>Extended
         <div class='outline t4 hide' id='hpi-current'>
            Documented Current Illness:
            <br><input type='checkbox' value='1' class='cpt hpi-current loca'>Location:                      
            <br><input type='checkbox' value='1' class='cpt hpi-current seve'>severity:                      
            <br><input type='checkbox' value='1' class='cpt hpi-current time'>timing:                        
            <br><input type='checkbox' value='1' class='cpt hpi-current qual'>Quality:                       
            <br><input type='checkbox' value='1' class='cpt hpi-current cont'>Context:                       
            <br><input type='checkbox' value='1' class='cpt hpi-current dura'>Duration:                      
            <br><input type='checkbox' value='1' class='cpt hpi-current fact'>Modifying Factors:             
            <br><input type='checkbox' value='1' class='cpt hpi-current sign'>Associated Signs and Symptoms: 
         </div>
         <div class='outline t4 hide' id='hpi-chronic'>
            Documented Number of Chronic Illness:
            <input class='cpt hpi-chronic' type='radio' name='hpi-chronic' value='0'>None
            <input class='cpt hpi-chronic' type='radio' name='hpi-chronic' value='1'>1 - 2
            <input class='cpt hpi-chronic' type='radio' name='hpi-chronic' value='2'>3 or more
         </div>
      </div>
      <div class='outline t3 hide' id='pfsh'>
         <a href='#' class='hidetoggle'>[ + ]</a> PFSH: 
         <input class='cpt pfsh' type='radio' value='0' name='pfsh'>N/A
         <input class='cpt pfsh' type='radio' value='1' name='pfsh'>Pertinent
         <input class='cpt pfsh' type='radio' value='2' name='pfsh'>Complete
         <div class='outline t4 hide' id='pfsh-parts'>
            Documented / Reviewed History
            <br><input class='cpt pfsh-parts' value='1' type='checkbox'>Past History (Past esperiences w/ illnesses, operations, inuries & treatements)
            <br><input class='cpt pfsh-parts' value='1' type='checkbox'>Family History (Medical events in the patient's family)
            <br><input class='cpt pfsh-parts' value='1' type='checkbox'>Social History (Age appropriate review of past and current activities).
         </div>
      </div>
      <div class='outline t3 hide' id='ros'>
         <a href='#' class='hidetoggle'>[ + ]</a> Review Of Systems(ROS):  
         <input class='cpt ros' type='radio' value='0' name='ros'>N/A
         <input class='cpt ros' type='radio' value='1' name='ros'>Problem Pertinent
         <input class='cpt ros' type='radio' value='2' name='ros'>Extended
         <input class='cpt ros' type='radio' value='3' name='ros'>Complete
         <div class='outline t4 hide' id='ros-detail'>
            Systems Reviewed (one must be related to problem(s) Identified in HPI:
            <br><input class='cpt ros-sys' type='checkbox' value='1'>Psychiatric
            <br><input class='cpt ros-sys' type='checkbox' value='1'>Constitutional Sympotoms
            <br><input class='cpt ros-sys' type='checkbox' value='1'>Eyes
            <br><input class='cpt ros-sys' type='checkbox' value='1'>Ears, Nose, Mouth, and Throat
            <br><input class='cpt ros-sys' type='checkbox' value='1'>Cardiovascular
            <br><input class='cpt ros-sys' type='checkbox' value='1'>Respiratory
            <br><input class='cpt ros-sys' type='checkbox' value='1'>Gastrointestinal
            <br><input class='cpt ros-sys' type='checkbox' value='1'>Musculoskeletal
            <br><input class='cpt ros-sys' type='checkbox' value='1'>Integumentary (skin and/or breast)
            <br><input class='cpt ros-sys' type='checkbox' value='1'>Neurological
            <br><input class='cpt ros-sys' type='checkbox' value='1'>Endocrine
            <br><input class='cpt ros-sys' type='checkbox' value='1'>Hematologic/Lymphatic
            <br><input class='cpt ros-sys' type='checkbox' value='1'>Allergic/Immunologic
         </div>
      </div>
   </div>
   <div class='outline t2' id='mdm'>
      <a href='#' class='hidetoggle'>[ + ]</a>MDM Type:<span id='mdmcode'></span>
      <input class='cpt mdm' name='mdm' type='radio' value='0'>N/A 
      <input class='cpt mdm' name='mdm' type='radio' value='1'>Straight Forward
      <input class='cpt mdm' name='mdm' type='radio' value='2'>Low 
      <input class='cpt mdm' name='mdm' type='radio' value='3'>Med 
      <input class='cpt mdm' name='mdm' type='radio' value='4'>High    
      <div id='problemsdiv' class='outline t3 hide'>
         <a href='#' class='hidetoggle'>[ + ]</a>Nubmer of diagnoses or management options: 
         <input class='cpt prob-item' type='radio' name='prob-score' value='0'>0 - 1
         <input class='cpt prob-item' type='radio' name='prob-score' value='2'>2
         <input class='cpt prob-item' type='radio' name='prob-score' value='3'>3
         <input class='cpt prob-item' type='radio' name='prob-score' value='4'>4 or more
         <div class='outline t4 hide'>
            Type:
            <input class='cpt prob-type' type='radio' name='prob-type-score_1' value='1'>minor
            <input class='cpt prob-type' type='radio' name='prob-type-score_1' value='2'>established
            <input class='cpt prob-type' type='radio' name='prob-type-score_1' value='3'>new
            <br>
            status:
            <input class='cpt prob-status' type='radio' name='prob-status-score_1' value='0'>n/a
            <input class='cpt prob-status' type='radio' name='prob-status-score_1' value='1'>better
            <input class='cpt prob-status' type='radio' name='prob-status-score_1' value='2'>stable
            <input class='cpt prob-status' type='radio' name='prob-status-score_1' value='3'>worse
            <br>
            Orders:
            <input class='cpt prob-orders' type='radio' name='prob-orders-score_1' value='0'>None
            <input class='cpt prob-orders' type='radio' name='prob-orders-score_1' value='1'>Some
            <br>
            <a href='#' onclick='javascript:insertElem("problemsdiv", this.parentNode.cloneNode(true));return false;'>more</a>
         </div>
      </div>
      <div id='datadiv' class='outline t3 hide'>
         <a href='#' class='hidetoggle'>[ + ]</a>Amount and/or complexity of data to be reviewed: 
         <input class='cpt data' type='radio' name='data-score' value='0'>0 - 1
         <input class='cpt data' type='radio' name='data-score' value='2'>2
         <input class='cpt data' type='radio' name='data-score' value='3'>3
         <input class='cpt data' type='radio' name='data-score' value='4'>4 or more
      
         <div id='datapartsdiv' class='outline t4 hide'>
                <input class='cpt data-item-part data-labs'      type='checkbox' value='1'>Review and/or Order of clinical lab orders
            <br><input class='cpt data-item-part data-radiology' type='checkbox' value='1'>Review and/or tests in the radiology section of CPT
            <br><input class='cpt data-item-part data-medical'   type='checkbox' value='1'>Review and/or tests in the medical section of CPT
            <br><input class='cpt data-item-part data-results'   type='checkbox' value='1'>Discussion of test results with performing physician
            <br><input class='cpt data-item-part data-records'   type='checkbox' value='1'>Decision to obtain old records and/or obtain history from someone other than patient
            <br><input class='cpt data-item-part data-summary'   type='checkbox' value='2'>Review and summarization of old records and/or obtaining history from someone other than patient and/or discussion of case with another health care provider  
            <br><input class='cpt data-item-part data-visual'    type='checkbox' value='2'>Independent visualization of image, tracing, or specimen itself (not simply review report)
         </div>
      </div>
      <div id='riskdiv' class='outline t3 hide'>
         <a href='#' class='hidetoggle'>[ + ]</a>Risk of significant complications, morbidity, and/or mortality: 
         <input class='cpt risk' type='radio' name='risk-score' value='1'>minimal
         <input class='cpt risk' type='radio' name='risk-score' value='2'>Low
         <input class='cpt risk' type='radio' name='risk-score' value='3'>Moderate
         <input class='cpt risk' type='radio' name='risk-score' value='4'>High
         <div id='risk-prob-div' class='outline t4 hide'>
            Problem: 
            <br><input class='cpt risk-prob' type='radio' name='risk-prob-score' value='1'>One Self-limited or minor problem
            <br><input class='cpt risk-prob' type='radio' name='risk-prob-score' value='2'>2 or more Self-limited or minor problem; 1 stable chronic; 1 acute uncomplicated
            <br><input class='cpt risk-prob' type='radio' name='risk-prob-score' value='3'>1 or more chronice w/ mild complications; 2 or more stable chronic; 1 undx new with uncertain prognosis; 1 acute w/ systemic symptoms
            <br><input class='cpt risk-prob' type='radio' name='risk-prob-score' value='4'>1 or more chronic w/ severe complications; 1 life/bodily function threating acute or chronic 
            <div id='risk-prob-parts-div' class='outline hide t5'>
               Problem Type:
               <input class='cpt prob risk-item' type='radio' name='risk-prob-type-score_1' value='1'>Self-limiting/Minor
               <input class='cpt prob risk-item' type='radio' name='risk-prob-type-score_1' value='2'>Acute
               <input class='cpt prob risk-item' type='radio' name='risk-prob-type-score_1' value='3'>Chronic
               <br>
               Problem status:
               <input class='cpt prob risk-item' type='radio' name='risk-prob-status-score_1' value='0'>N/A
               <input class='cpt prob risk-item' type='radio' name='risk-prob-status-score_1' value='1'>Stable
               <input class='cpt prob risk-item' type='radio' name='risk-prob-status-score_1' value='2'>Mild Exacerbation, progression, or side effects
               <input class='cpt prob risk-item' type='radio' name='risk-prob-status-score_1' value='1'>Severe Exacerbation, progression, or side effects
               <input class='cpt prob risk-item' type='radio' name='risk-prob-status-score_1' value='1'>Life Threatening
            </div>
         </div>
         <div id='risk-order-div' class='outline t4 hide'>
            Orders:
            <br><input class='cpt risk-order' type='radio' name='risk-order-score' value='1'>Laboratory tests requiring venipuncture Chest x-rays EKG/EEG Urinalysis Ultrasound, eg, echocardiography KOH prep
            <br><input class='cpt risk-order' type='radio' name='risk-order-score' value='2'>Physiologic tests not under stress, eg, pulmonary function tests Non-cardiovascular imaging studies with contrast, eg, barium enema Superficial needle biopsies Clinical laboratory tests requiring arterial puncture Skin biopsies
            <br><input class='cpt risk-order' type='radio' name='risk-order-score' value='3'>Physiologic tests under stress, eg, cardiac stress test, fetal contraction stress test Diagnostic endoscopies with no identified risk factors Deep needle or incisional biopsy Cardiovascular imaging studies with contrast and no identified risk factors, eg, arteriogram, cardiac catheterization Obtain fluid from body cavity, eg lumbar puncture, thoracentesis, culdocentesis
            <br><input class='cpt risk-order' type='radio' name='risk-order-score' value='4'>Cardiovascular imaging studies with contrast with identified risk factors Cardiac electrophysiological tests Diagnostic Endoscopies with identified risk factors Discography
         </div>
         <div id='risk-option-div' class='outline t4 hide'>
            Management Options:
            <br><input class='cpt risk-option' type='radio' name='risk-option-score' value='1'>Rest Gargles Elastic bandages Superficial dressings
            <br><input class='cpt risk-option' type='radio' name='risk-option-score' value='2'>Over-the-counter drugs Minor surgery with no identified risk factors Physical therapy Occupational therapy IV fluids without additives
            <br><input class='cpt risk-option' type='radio' name='risk-option-score' value='3'>Minor surgery with identified risk factors Elective major surgery (open, percutaneous or endoscopic) with no identified risk factors Prescription drug management Therapeutic nuclear medicine IV fluids with additives Closed treatment of fracture or dislocation without manipulation
            <br><input class='cpt risk-option' type='radio' name='risk-option-score' value='4'>Elective major surgery (open, percutaneous or endoscopic) with identified risk factors Emergency major surgery (open, percutaneous or endoscopic) Parenteral controlled substances Drug therapy requiring intensive monitoring for toxicity Decision not to resuscitate or to de-escalate care because of poor prognosis
         </div>
      </div>
   </div>
</div>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.2.min.js'></script>
<script type='text/javascript' src='../js/cpt.js'></script>
<script type='text/javascript'>
   var mycpt;
   $(document).ready(function(){
      $('.patient').change(function(){
         $(this).parent().children('div').hide();
         var divid = '#' + this.name + '-' + this.value;
         $('#' + this.name + '-' + this.value).show()
         $('#time-' + this.value).show();
      });
         
   });
   var mychange = function(){
      var input = {
         patient:$('.patient:checked').val()?$('.patient:checked').val():0
         ,map: $('.em-codes').get()
         ,time: {
            overhalf: $('#overhalf:checked').val()
            ,duration: $('.duration:checked').val()
         }
         ,exam:  $('#exam').children('div').not(':visible').length?
            $('.exam:checked').val()?$('.exam:checked').val():0:
               {
                  constitutional: $('.cons:checked').length
                  ,musculoskeletal: $('.musc:checked').length
                  ,psychiatric: $('.psych:checked').length
                  ,map: $('.exam').get()
               }
         ,hist: $('#hist').children('div').not(':visible').length?
            ($('.history:checked').val()?$('.history:checked').val():0):
            {
               cc: $('#cc').children('div').not(':visible').length?
                  ($('.cc').val()?$('.cc:checked').val():0):
                  {  
                     symptom: $('#symp').val().length
                     ,problem: $('#prob').val().length
                     ,condition: $('#cond').val().length
                     ,diagnosis: $('#dx').val().length
                     ,'recommended return': $('#recom').val().length
                     ,'other factor': $('#other').val().length
                     ,map: $('.cc').get()
                  }
               ,hpi: $('#hpi').children('div').not(':visible').length?
                  ($('.hpi:checked').val()?$('.hpi:checked').val():0):
                     {
                        current: {
                           total_count: $('.hpi-current:checked').length
                        }
                        ,chronic: {
                           count: $('.hpi-chronic:checked').val()
                        }
                        ,map: $('.hpi').get()
                     }
               ,ros: $('#ros').children('div').not(':visible').length?
                  $('.ros:checked').val()?$('.ros:checked').val():0:
                  {
                     total_count: $('.ros-sys:checked').length
                     ,map: $('.ros').get()
                  }
               ,pfsh: $('#pfsh').children('div').not(':visible').length?
                  $('.pfsh:checked').val()?$('.pfsh:checked').val():0:
                  {
                     total_count: $('.pfsh-parts:checked').length
                     ,map: $('.pfsh').get()
                  }
               ,map: $('.history').get()
            }
         ,mdm: $('#mdm').children('div').not(':visible').length?
            $('.mdm:checked').val()?$('.mdm:checked').val():0:
            {
               prob: $('#problemsdiv').children('div').not(':visible').length?
               $('.prob-item:checked').val()?$('.prob-item:checked').val():0:
                  {
                     prob_itm: {
                        items: function(container){
                           var out = [];
                           for(kids in container.childNodes){
                              if (container.childNodes[kids].nodeName === 'DIV') {
                                 out.push({
                                    type: $(container.childNodes[kids]).children('.prob-type:checked').val(),
                                    status: $(container.childNodes[kids]).children('.prob-status:checked').val(),
                                    orders:$(container.childNodes[kids]).children('.prob-orders:checked').val()
                                 });
                              }
                           }
                           return out;
                        }(document.getElementById('problemsdiv'))
                     }
                     ,map: $('.prob-item').get()
                  } 
               ,data: $('#datadiv').children('div').not(':visible').length?
                  $('.data:checked').val()?$('.data:checked').val():0:
                  { 
                     labs:  $('.data-labs:checked').val()
                     ,radiology:  $('.data-radiology:checked').val()
                     ,medicine:   $('.data-medical:checked'  ).val()
                     ,results:   $('.data-results:checked'  ).val()
                     ,records:   $('.data-records:checked'  ).val()
                     ,summary:   $('.data-summary:checked'  ).val()
                     ,visual:    $('.data-visual:checked'   ).val()
                     ,map: $('.data').get()
                  }
               ,risk: $('#riskdiv').children('div').not(':visible').length?
                  $('.risk:checked').val()?$('.risk:checked').val():0:
                  {
                     problems: $('#risk-prob-div').children('div').not(':visible').length?
                        $('.risk-prob:checked').val()?$('.risk-prob:checked').val():0:0
                     ,orders: $('.risk-order:checked').val()?$('.risk-order:checked').val():0
                     ,options: $('.risk-option:checked').val()?$('.risk-option:checked').val():0
                     ,map: $('.risk').get()
                  }
               ,map: $('.mdm').get() 
            }
      };
//      console.log(em);
      var output = em.calculate(input);
//      console.log(input, output, em);
   }
   $('input').change(mychange);
   $('.hidetoggle').click(function(){
      if($(this).html() === '[ - ]') {
         $(this).html('[ + ]').parent().children('div').hide();
      }else{
         $(this).html('[ - ]').parent().children('div').show();
      }
      mychange();
      return false;
   });
   function insertElem(id, node) {
      document.getElementById(id).appendChild(
         function(node){
            for (var i=0; i<node.childNodes.length; i++){
               if (node.childNodes[i].name){
                  var parts=node.childNodes[i].name.split("_");
                  node.childNodes[i].name=parts[0]+"_"+(parseInt(parts[1])+1);
                  node.childNodes[i].checked=false;
               }
            }
            node.onchange = mychange;
            return node;
         }(node));
      return false;
   }

</script>
</body>
</html>